**********************************************
*This file replicates the empirical analysis presented in "A Pact With The Devil: The Madman Theory and Nonaggression Pacts"
**********************************************
* Yinlong Li
* 9/26/24

**********************************************
*Open data;
clear
log using "LiFPArep.smcl", replace 


**********************************************
*** Table 1***
**********************************************
use "C:\FPA Replication\Leader-Year Crazy Scores.dta", clear
duplicates drop leadid year, force
collapse (sum) modcrazy15_nolag reallycrazy15_nolag crazyscoresum (mean) crazyscore, by(leadid leader ccode)
gsort -crazyscoresum


**********************************************
*** Main Models***
**********************************************
use "C:\FPA Replication\LiFPArep.dta", clear

**********************************************
***Table 2:
**********************************************
*****Model 1:
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)
*****Model 2:
probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)
*****Model 3:
probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

***** Substantive Effects;
*****Figure 1:
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

margins, atmeans at( reallycrazy15 =(0 (1) 1)) noatlegend
marginsplot, title("Predicted Probability of Nonaggression Pacts") ytitle("Probability of Forming Nonaggression Pacts") xtitle("Strong Madness Reputation") title("") ciopt(color(gray)) recast(scatter)

margins, atmeans at( modcrazy15 =(0 (1) 1)) noatlegend
marginsplot, title("Predicted Probability of Nonaggression Pacts") ytitle("Probability of Forming Nonaggression Pacts") xtitle("Slight Madness Reputation") title("") ciopt(color(gray)) recast(scatter)

*****Figure 2;
probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

margins, dydx(reallycrazy15) at( distance =(0 (1) 12)) noatlegend
marginsplot, title("Marginal Effect of Strong Madness Rep. on Distance") ytitle("Marginal Effect of Strong Madness Rep.") xtitle("Distance") title("") recastci(rarea) ciopt(color(gray)) recast(line)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

margins, dydx(reallycrazy15) at( smallcincnumberally =(0 (1) 20)) noatlegend
marginsplot, title("Marginal Effect of Strong Madness Rep.") ytitle("Marginal Effect of Strong Madness Rep.") xtitle("Number of Alliances") title("") recastci(rarea) ciopt(color(gray)) recast(line)



***********************************************
***** Tables and figures included in the Appendix *****
***********************************************
***** Figure 3;
*Madness Reputation Distribution;
use "C:\FPA Replication\Leader-Year Crazy Scores.dta", clear
quantile crazyscore if crazyscore>0, recast(area) ytitle(Value of Madness Reputation) xtitle(Percentile among Observations (Non-Zero Values)) title(Madness Reputation Distribution (Non-Zero Values))
graph export "C:\FPA Replication\Madness Reputation Distribution.pdf", as(pdf) name("Graph")

*****Table 3;
*DETERMINANTS OF PERCEIVED MADNESS;
use "C:\FPA Replication\Leader-Year Crazy Scores.dta", clear
duplicates drop leadid year crazyscore modcrazy15_nolag reallycrazy15_nolag dem gwf_personal realgdp rebel milservice age gender yrs_in_ofc leveledu recentMIDs_byleader gdp_change_l1, force

*Continuous Measure;
tobit crazyscore dem gwf_personal realgdp rebel milservice age gender yrs_in_ofc leveledu recentMIDs_byleader gdp_change_l1 cinc majorpower number rogue allianceformation other_rivals war wartime , ll(0)
*Slight Madness;
probit modcrazy15_nolag dem gwf_personal realgdp rebel milservice age gender yrs_in_ofc leveledu recentMIDs_byleader gdp_change_l1 cinc majorpower number rogue allianceformation other_rivals war wartime  , cluster(leadid)
*Strong Madness;
probit reallycrazy15_nolag dem gwf_personal realgdp rebel milservice age gender yrs_in_ofc leveledu recentMIDs_byleader gdp_change_l1 cinc majorpower number rogue allianceformation other_rivals war wartime , cluster(leadid)

*****Table 4;
use "C:\FPA Replication\LiFPArep.dta", clear
*fixed effects;
*year fixed effects;

probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.year, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i. year, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.year, cluster(dyadid)

*****Table 5;
*regional fixed effects;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.regiona i.regionb, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.regiona i.regionb, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.regiona i.regionb, cluster(dyadid)

*****Table 6;
*country fixed effects;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.stateA i.stateB, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.stateA i.stateB, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub i.stateA i.stateB, cluster(dyadid)

*****Table 7;
*dyad fixed effects;
xtset dyad year
xtlogit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, fe

xtlogit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, fe

xtlogit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, fe

*****Table 8;
**Address Pro-Western Bias and Strategic Use of Madness Adjectives;
*// Control for affinity with the US;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub affinity_us_a affinity_us_b, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub affinity_us_a affinity_us_b, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub affinity_us_a affinity_us_b, cluster(dyadid)

*****Table 9;
// Use only non-US sources
probit nonagg reallycrazy15_nonus modcrazy15_nonus joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

probit nonagg reallycrazy15_nonus modcrazy15_nonus reallycrazydistance_nonus modcrazydistance_nonus joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

probit nonagg reallycrazy15_nonus modcrazy15_nonus reallycrazynumberally_nonus modcrazynumberally_nonus joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*****Table 10;
// Drop Major Western Countries;
drop if stateA==2 | stateA==20 | stateA==200 | stateA==255 | stateA==220 | stateA==325 | stateA==740 | stateB==2 | stateB==20 | stateB==200 | stateB==255 | stateB==220 | stateB==325 | stateB==740

probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*****Table 11;
use "C:\FPA Replication\LiFPArep.dta", clear
*drop rogue states;
drop if rogue==1

probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*****Table 12;
use "C:\FPA Replication\LiFPArep.dta", clear

*level of external threats;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub smallcincthreat, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub smallcincthreat, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub smallcincthreat, cluster(dyadid)

*****Table 13;
*UN voting;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub UN_voting, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub UN_voting, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub UN_voting, cluster(dyadid)

*****Table 14;
*addtional controls;
*interaction between cinc_per and number of alliances;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub smallcincallycincper, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub smallcincallycincper, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub smallcincallycincper, cluster(dyadid)

*****Table 15;
*years in the office;
probit nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub moremadyrs_in_ofc, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazydistance modcrazydistnace joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub moremadyrs_in_ofc, cluster(dyadid)

probit nonagg reallycrazy15 modcrazy15 reallycrazynumberally modcrazynumberally joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub moremadyrs_in_ofc, cluster(dyadid)

*****Table 16;
*addtional interactions;
*rivals;
probit nonagg reallycrazy15 modcrazy15 reallycrazyrival modcrazyrival joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*geographic neighbors
probit nonagg reallycrazy15 modcrazy15 reallycrazycontiguous modcrazycontiguous joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*recent mid;
probit nonagg reallycrazy15 modcrazy15 reallycrazyrecentmid modcrazyrecentmid joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*nato/warsaw member;
probit nonagg reallycrazy15 modcrazy15 reallycrazynatowarsaw modcrazynatowarsaw joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub lessmadnatowarsaw, cluster(dyadid)

*nuclear weapons;
probit nonagg reallycrazy15 modcrazy15 reallycrazymdc modcrazymdc joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub lessmadmdc, cluster(dyadid)

*democracy;
probit nonagg reallycrazy15 modcrazy15 reallycrazydem modcrazydem joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub lessmaddem, cluster(dyadid)


*****Table 17;
*placebo test;
*defense pacts;
probit defense reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*neutral pacts;
probit neutral reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*consul pacts;
probit consul reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)

*pure nonaggression pacts;
probit pure_nonagg reallycrazy15 modcrazy15 joint_democracy polity_diff majorpower distance rivalry rivalry_time cinc madrecentmid smallcincnumberally smallcincneighbor smallercincrivals peaceyrs peaceyrs_sq peaceyrs_cub, cluster(dyadid)



**********************************************
log close
**********************************************

